<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Jedrzej\Pimpable\PimpableTrait;
use Illuminate\Database\Eloquent\SoftDeletes;

class ProductRule extends Model
{
    use HasFactory;
    use PimpableTrait;
    use SoftDeletes;

    /**
     * 表中的类型状态 无
     */

    /**
     * 可搜索字段
     */
    public $searchable = [
        'id',
        'title'
    ];

    /**
     * 可批量赋值字段
     */
    public $fillable = [
        'title',
        'content',
        'system_admin_id'
    ];

    /**
     * 可排序字段
     */
    public $sortable = ['created_at', 'id'];

    /**
     * 默认排序字段
     */
    protected $defaultSortCriteria = ['id,desc'];

    /**
     * 强制转换类型
     */
    protected $casts = [
        'content' => 'array'
    ];

    /**
     * 查询字段模式
     *
     *  nickname => '%field%' 模糊查询
     *  created_at= (ge)field
     * @var array
     */
    public $searchableModels = [
        'title' => '%field%'
    ];
}
